import java.io.*;
import java.util.Scanner;

/**
 * @Auther: MFM
 * @Date: 2021/10/30 - 10 - 30 - 20:30
 * @version: 1.0
 */

public class pra {
    public static void main(String[] args) throws Exception {

        class CopyFileThread extends Thread {
            private File file = null;

            public CopyFileThread(File file) {
                this.file = file;
            }

            public void run() {
                try {
                    InputStream stream = new FileInputStream(file);
                    byte[] datas = new byte[1024];
                    OutputStream out = new FileOutputStream("D:/123/" + file.getName());
                    int size = -1;
                    while ((size = stream.read(datas)) > 0) {
                        out.write(datas, 0, size);
                    }
                    stream.close();
                    out.close();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }

        File directory = new File("D:/新建文件夹");
        File[] files = directory.listFiles();
        for (File file : files) {
            new CopyFileThread(file).start();
        }
    }

}
